using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using Framework.Library.Core.Config;
using Framework.Library.Core.Data.DataEngine;
using Framework.Library.Data.DAL;
using Framework.Library.Data.IDAO;
using Framework.Library.Core.Utils.Database;
using System.Text;

namespace Framework.Library.Data.DAO.Oracle
{
    [Serializable]
    internal class TeenioCategoryManager : ITeenioCategoryManager
    {
        private Configurations cfg = new Configurations();
        #region ICMSContentManager Members        

        public List<TeenioCategory> GetCategoriesByPortal(int portalID)
        {
            QueryBuilder builder = new QueryBuilder("TEENIO_CATEGORIES");
            StringBuilder sb = new StringBuilder();
            sb.Append("SELECT NS_TEENIO_CATEGORIES.* FROM " + Configurations.DATABASEOWNER + "TEENIO_CATEGORIES inner join " + Configurations.DATABASEOWNER + "PORTAL_MENU on " + Configurations.DATABASEOWNER + "TEENIO_CATEGORIES.MENUID = " + Configurations.DATABASEOWNER + "PORTAL_MENU.ID ");
            sb.Append("WHERE " + Configurations.DATABASEOWNER + "PORTAL_MENU.PORTALID = @PORTALID ");
            sb.Append("ORDER BY " + Configurations.DATABASEOWNER + "TEENIO_CATEGORIES.ZONE_ID DESC");
            builder.Query = sb.ToString();
            builder.Parameters = new ArrayList() { new object[] { "PORTALID", portalID } };
            builder.QueryType = QueryTypes.TSql;
            return GeneralConnection.ExecuteList<TeenioCategory>(CommandType.Text, builder);
        }
        
        #endregion
    }
}